<template>
    <div class="home">
        <div class="Recone">
            <div class="Reconefle">
                <div class="Recleft">
                    <div  @click="ChoseRadom(poeamList)" v-bind="poeamList">开始推荐</div>
                    <div  v-html="randomItem.neirong">
                        
                    </div>
                </div>

                <div class="Recright">
                    <ul class="Recright_top u-f" @click="Choseup" >
                        <img src="../../assets/up.svg" alt="">
                    </ul>
                    <ul class="Recright_middle u-f" >
                        <img src="../../assets/like.svg" alt="">
                    </ul>
                    <ul class="Recright_bottom u-f" @click="Chosedown" > 
                        <img src="../../assets/down.svg" alt="">
                    </ul>
                </div>
            </div>
            
        </div>
    </div>
</template>

<script>
export default {
    methods:{
        ChoseRadom(item){
            if(item.length>0){
                this.randomItem = item[Math.floor(Math.random() * item.length)];
                console.log(this.randomItem);
                this.ReadHis.push(this.randomItem)
                for(var i = 0; i < item.length; i++){
                    if(item[i].id === this.randomItem.id){
                        item.splice(i,1);
                        
                        this.ReadHisNumber = this.ReadHis.length;
                        console.log(this.ReadHisNumber)
                    }
                }
            }else{
                alert('今日推荐已阅读完')
            }
           
            // let length  = this.ReadHIs.length
            // this.ReadHisNumber = length;

        },
        Choseup(){
            if(this.ReadHisNumber>1){
                this.randomItem = this.ReadHis[this.ReadHisNumber-2];
                console.log(this.ReadHisNumber)
                 console.log(this.ReadHis[this.ReadHisNumber-1])
                return this.ReadHisNumber--;
            }else{
                alert('已经是第一条了')
            }
        },
        Chosedown(){
            if(this.ReadHisNumber<this.ReadHis.length){
                this.randomItem = this.ReadHis[this.ReadHisNumber];
                return this.ReadHisNumber++;
            }else{
                
                alert('已经是最后一条了')
            }
        }
    },
    data(){
        return{
            randomItem:'',
            ReadHis:[],
            Choserun:true,
            ReadHisNumber:0,
            poeamList:[
                {
                    id:'',
                    name:'',
                    neirong:'',
                },{
                    id:'',
                    name:'',
                    neirong:'',
                },{
                    id:'',
                    name:'',
                    neirong:'',
                }
                ,{
                    id:'',
                    name:'',
                    neirong:'',
                }
                ,{
                    id:'',
                    name:'',
                    neirong:'',
                }
                ,{
                    id:'',
                    name:'',
                    neirong:'',
                }
                ,{
                    id:'',
                    name:'',
                    neirong:'',
                }
                
            ]
        }
    }
}
</script>

<style>

</style>
